<!DOCTYPE HTML>
<html>
<head>
    {include file="common:meta"}
</head>
<body>
<div class="page-container">
    <div class=" float-e-margins">
        <div class="ibox-content">
            <div class="tabs-container">
                <div class="tab-content">
                    <div class=" tab-pane active" id="tab-1">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>房主ID</th>
                                <th>房间名</th>
                                <th>标签名</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="data"  id="list"}
                            <tr>
                                <td style="display: none;">{$list.id}</td>
                                <td>{$list.u_id}</td>
                                <td>{$list.r_name}</td>
                                <td>{$list.t_name}</td>
                                <td>
                                    <button  type="button"  onclick="ChangeStatus(this)" class="btn btn-warning btn-sm">
                                        {if $list.status == 1 } 禁用
                                        {else /} 启用
                                        {/if}
                                    </button>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                    {$data|raw}
                </div>
            </div>
        </div>
    </div>
</div>
{include file="common:footer"}

<script>


    function ChangeStatus(obj){
        var id = $(obj).parent().siblings().eq(0).text();
        console.log(id);
        console.log($(obj).text());

        var status = $(obj).text();

        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '/LabelRoomChangeStatus',
            data: {'id': id},
            success: function (re) {
                if (re.code === 100) {
                    if(status === '禁用') status = '启用';
                    else status = '禁用';
                    layer.msg(re.msg, {icon: 1, time: 2000});
                    $(obj).text(status)
                } else {
                    layer.msg(re.msg,{icon: 2, time: 2000});
                }
            },
            error: function (data) {
                layer.msg('服务器出小差了');
            }
        });

    }




</script>
</body>
</html>